package com.project.service.impl;

import com.project.bean.UserBean;
import com.project.mapper.IManMapper;
import com.project.service.IManService;
import org.apache.ibatis.session.SqlSession;

import java.time.LocalDate;

/**用户业务接口实现类*/
public class ManServiceImpl extends BaseService implements IManService {

    @Override
    public void add(UserBean user) {

        //得到session对象
        SqlSession session = this.getSession();
        //得到一个IManMapper接口的实现类对象
        IManMapper mapper = session.getMapper(IManMapper.class);
        //调用mapper中的add
        mapper.add(user);

        //提交事务
        session.commit();
        //关闭session
        session.close();
    }

    @Override
    public void del(int id) {

        SqlSession session = this.getSession();
        IManMapper mapper = session.getMapper(IManMapper.class);
        mapper.del(id);

        session.commit();
        session.close();

    }

    @Override
    public void update(int id, LocalDate birthday) {

        SqlSession session = this.getSession();
        IManMapper mapper = session.getMapper(IManMapper.class);
        mapper.update(id,birthday);

        session.commit();
        session.close();
    }
}
